// file name: inst_test.h
#include <inst_def.h>


#define TEST_ADD(vs, vt, vd) \
    ADD(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_ADDU(vs, vt, vd) \
    ADDU(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_ADDIU(vs, vt, vd) \
    ADDIU(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_ANDI(vs, vt, vd) \
    ANDI(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_LUI(imm, vt) \
    LUI(imm); \
    li s0, vt; \
    bne t0, s0, inst_error; \
    nop

#define TEST_OR(vs, vt, vd) \
    OR(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_ORI(vs, vt, vd) \
    ORI(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_XOR(vs, vt, vd) \
    XOR(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_XORI(vs, vt, vd) \
    XORI(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_SLL(vs, vt, vd) \
    SLL(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_SLLV(vs, vt, vd) \
    SLLV(vs, vt); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop



#define TEST_BEQ(vs0, vs1, back_flag, front_flag, b_flag_ref, f_flag_ref) \
    BEQ(vs0, vs1, back_flag, front_flag); \
    li s4, b_flag_ref; \
    bne s0, s4, inst_error; \
    nop; \
    li s5, f_flag_ref; \
    bne s2, s5, inst_error; \
    nop


#define TEST_BNE(vs0, vs1, back_flag, front_flag, b_flag_ref, f_flag_ref) \
    BNE(vs0, vs1, back_flag, front_flag); \
    li s4, b_flag_ref; \
    bne s0, s4, inst_error; \
    nop; \
    li s5, f_flag_ref; \
    bne s2, s5, inst_error; \
    nop


#define TEST_BLEZ(vs0, back_flag, front_flag, b_flag_ref, f_flag_ref) \
    BLEZ(vs0, back_flag, front_flag); \
    li s4, b_flag_ref; \
    bne s0, s4, inst_error; \
    nop; \
    li s5, f_flag_ref; \
    bne s2, s5, inst_error; \
    nop

/* 47
 * TEST_LB(data, base_addr, offset, offset_align, vd)
 */
#define TEST_LB(data, base_addr, offset, offset_align, vd) \
    LB(data, base_addr, offset, offset_align); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_LW(data, base_addr, offset, offset_align, vd) \
    LW(data, base_addr, offset, offset_align); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop

#define TEST_SB(data_init, data, base_addr, offset, offset_align, vd) \
    SB(data_init, data, base_addr, offset, offset_align); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop


#define TEST_SW(data, base_addr, offset, offset_align, vd) \
    SW(data, base_addr, offset, offset_align); \
    li s2, vd; \
    bne s0, s2, inst_error; \
    nop